//
//  VCOfMessage.m
//  UI09_UITabBarController
//
//  Created by Scott on 16/5/13.
//  Copyright © 2016年 Scott. All rights reserved.
//

#import "VCOfMessage.h"

@interface VCOfMessage ()

@property (nonatomic, retain) UITextField *tf;
@property (nonatomic, retain) UIButton *button;

@end

@implementation VCOfMessage

- (void)dealloc {
    
    [_tf release];
    [_button release];
    [super dealloc];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.view.backgroundColor = [UIColor greenColor];
    
    [self createTextField];
}


- (void)createTextField {
    
    self.tf = [[UITextField alloc] initWithFrame:CGRectMake(20, 100, 300, 40)];
    [self.view addSubview:self.tf];
    [_tf release];
    
    self.tf.backgroundColor = [UIColor cyanColor];
    
    
    self.button = [UIButton buttonWithType:UIButtonTypeSystem];
    
    self.button.frame = CGRectMake(50, 200, 200, 40);
    
    [self.button setTitle:@"获取字符串" forState:UIControlStateNormal];
    
    [self.view addSubview:self.button];
    
    self.button.backgroundColor = [UIColor yellowColor];
    
    [self.button addTarget:self action:@selector(comfirmAction) forControlEvents:UIControlEventTouchUpInside];
}

- (void)comfirmAction {

    
    NSString *path = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject] stringByAppendingPathComponent:@"use.txt"];
    
    // Core API
    NSString *str = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:nil];
    
    self.tf.text = str;
    
    
    NSData *data = [NSData dataWithContentsOfURL:@"http://pic33.nipic.com/20130913/13008390_223449507127_2.jpg"];
    
    NSLog(@"%@", data);
    
}





@end
